﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace wpf_print.view
{
    internal class BoxView
    {
        public static WrapPanel GetBoxView(JObject item) {
            WrapPanel warPanel = new()
            {
                Orientation = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Center,
                Width = (double)item["cssStyle"]["width"]
            };
            TextBlock textContent = new();
            if ((string)item["cssStyle"]["fontWeight"] == "bold")
            {
                textContent.FontWeight = FontWeights.Bold;
            }
            textContent.FontSize = (double)item["cssStyle"]["fontSize"];
            textContent.TextWrapping = TextWrapping.Wrap;
            textContent.Width = (double)item["cssStyle"]["width"];
            textContent.LineHeight = (double)item["cssStyle"]["fontSize"];
            textContent.Text = (string)item["name"] + (string)item["value"];
            warPanel.Children.Add(textContent);
            warPanel.VerticalAlignment = VerticalAlignment.Top;
            return warPanel;


        }
    }
}
